<template>
  <div class="articles">
    <articlesItem
      v-for="(item, index) in lists"
      :key="index"
      :item="item"
      @click.native="btn(item.art_id)"
      @delete="deletebtn"
    ></articlesItem>
  </div>
</template>

<script>
export default {
  // 组件名称
  name: 'articles',
  // 组件参数 接收来自父组件的数据
  props: {
    lists: {
      type: Array,
      default () {
        return []
      }
    }
  },
  // 局部注册的组件
  components: {},
  // 组件状态值
  data () {
    return {
    }
  },
  methods: {
    btn (id) {
      this.$router.push('/articlesinfo/' + id)
    },
    // 不感兴趣删除文章功能
    deletebtn (id) {
      const i = this.lists.find(ele => {
        return ele.art_id == id
      })
      const num = this.lists.indexOf(i)
      this.lists.splice(num, 1)
    }
  }
}
</script>
<style scoped>
</style>
